This knowledge organiser summarises the Python programming skills you have practised in this lesson.
You should be able to read, write, and explain programs that use these skills.
input() pauses the program and waits for the userprint() displays information to the user
name = input("Enter your name: ")
print(f"Hello {name}")
Why this works: The input is stored in a variable and reused in the output.
input() is stored as textstr – textint – whole numbersfloat – decimal numbers
num = int(input("Enter a number: "))
print(num * 2)
Exam reminder:
Without int(), Python treats numbers as text.
if checks the first conditionelif checks additional conditionselse runs if none are true
colour = input("Enter a colour: ")
if colour.lower() == "red":
print("Correct")
elif colour.lower() == "blue":
print("Correct")
else:
print("Incorrect")
Why .lower() matters:
It avoids errors caused by capital letters.
password = input("Enter password: ")
while password != "Secret123":
print("Incorrect")
password = input("Try again: ")
print("Password accepted")
Important rule: The variable used in the condition must be updated.
while True mean?break is used to exit the loopbreak runs
while True:
guess = input("Enter a colour: ")
if guess.lower() == "red":
print("Correct")
break
else:
print("Incorrect")
Exam tip: Always explain where and why the loop ends.
range()range(start, end)
for i in range(1, 13):
print(f"{i} x 8 = {i * 8}")
Common error: Expecting the loop to include the final value.
sports = ["Shotput", "Javelin", "Diving"]
for i in range(0, 3):
print(sports[i])
Exam tip: Index values always start at 0.
landmarks = [
["Eiffel Tower", "Paris"],
["Big Ben", "London"],
["Sagrada Familia", "Barcelona"]
]
print(landmarks[0][0])
print(landmarks[0][1])
Outputs:
Eiffel Tower Paris
for i in range(0, len(landmarks)):
if landmarks[i][1] == "Paris":
print(landmarks[i][0])
Outputs:
Eiffel Tower